package com.bacsumu.boogservice.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.bacsumu.boogservice.entity.HelloWorld;
import com.bacsumu.boogservice.service.HelloWorldService;


//컨트롤러라는 annotation
@Controller
public class HelloWorldController {
	
	@Autowired
	HelloWorldService	helloWorldService;
	
	
	public HelloWorldService getHelloWorldService() {
		return helloWorldService;
	}

	public void setHelloWorldService(HelloWorldService helloWorldService) {
		this.helloWorldService = helloWorldService;
	}

	// 서블릿 매핑 /helloworld.htm
	@RequestMapping("/helloworld.htm")
	public ModelAndView helloWord(){
		String message = "Hello World, Spring 3.0!";
		return new ModelAndView("helloworld", "message",message);
	}
		
	@RequestMapping("/helloworld_save.htm")
	public ModelAndView helloWordSave(){
		
		HelloWorld l_helloWorld = new HelloWorld();
		l_helloWorld.setHelloName("aaa");
		
		helloWorldService.create(l_helloWorld);
		
		String message = "Hello World Saved";
		return new ModelAndView("helloworld", "message",message);
	}
}
